<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>时钟</title>
    <style>
        .clock {
            background: url(./images/clock.png) no-repeat center center;
            width: 300px;
            height: 300px;
            position: relative;
            margin:0 auto;
        }
        .hours {
            background-color: #000;
            width: 8px;
            height: 70px;
            position: absolute;
            left: 146px;
            top: 115px;
        }
        .minute {
            background-color: #666;
            width: 4px;
            height: 90px;
            position: absolute;
            left: 148px;
            top: 105px;
        }
        .seconds {
            background-color: #999;
            width: 2px;
            height: 110px;
            position: absolute;
            left: 149px;
            top: 95px;
        }
    </style>
</head>
<body>
    <div class="clock">
        <div class="hours"></div>
        <div class="minute"></div>
        <div class="seconds"></div>
    </div>
</body>
<script>
    const run = () => {
        const date = new Date()
        const seconds = date.getSeconds()
        const minute = date.getMinutes()
        let hours = date.getHours()
        if (hours >= 12) {
            hours -= 12
        }
        const hoursEl = document.querySelector('.hours')
        const minuteEl = document.querySelector('.minute')
        const secondsEl = document.querySelector('.seconds')

        hoursEl.style.transform = `rotate(${(hours + minute / 60) * 30}deg) translateY(-35px)`
        minuteEl.style.transform = `rotate(${(minute + seconds / 60) * 6}deg) translateY(-35px)`
        secondsEl.style.transform = `rotate(${seconds * 6}deg) translateY(-35px)`
    }
    run()
    setInterval(() => {
        run()
    })
</script>
</html>